package org.display.util
{
	import org.data.HashMap;
	import org.utils.*;

	public class CreateChart
	{
		var paths:Array=[]
			
		var pathMap:HashMap=new HashMap()
			
		var items:Array=[]	
			
		public function CreateChart()
		{
		}
		
		//第一步导入所有xml
		function loadAllxml(){

			FileControl.readFile(paths,Global.workspace+"\\xml")
	
			loadxml(paths.concat())

		    function loadxml(paths:Array){
			
			var res:AbcResponder=new AbcResponder()
			
			res.onResult=function(e,path){
				
				pathMap[path] = e

				if(paths.length>0){
					
					loadxml(paths.shift())
					
				}else{
				    
					createItems()
				    
				}
			
			}
			
			new AbcHTTPServices(paths.shift(),res)
			
		    }
		
		}
		
		//获取每个xml的所有子项
		
		function createItems(){
		
			for(var i=0;i<paths.length;i++){
				
				items.push(getChildren(paths[i]))
				
			}

		}
	
	   //获取一个模块所有的子模块
	   function getChildren(path:String):Array{
		
		var childs:Array=[]
		
		createItem(path)
		
		childs.reverse()
		
		return childs
		
		function createItem(path:String){
			
			var source:XML=XML(pathMap[path])
			
			childs.push(path)
			
			var values:Array=source.items
			
			for(var i=0;i<values.length;i++){
				
				if(values[i].path!=undefined){
					
					createItem(values[i].path)
					
				}
				
			}
			
		   }
	    }
		
		
       
		function doJsfl(){
		   
			
		
		
		
		
		
		
		}
		
		
	}
}